using System.Web.Mvc;
using DemoLib.Service.Client;
using DemoLib.Service.Client.Clients;
using DemoLib.Shared.Contracts;
using Microsoft.Practices.Unity;
using Mvc3Demo.Core;

namespace Mvc3Demo
{
    public static class Bootstrapper
    {
        public static void Initialise()
        {
            var container = BuildUnityContainer();

            DependencyResolver.SetResolver(new UnityDependencyResolver(container));
        }

        private static IUnityContainer BuildUnityContainer()
        {
            var container = new UnityContainer();

            // register all your components with the container here
            // it is NOT necessary to register your controllers
            
            // e.g. container.RegisterType<ITestService, TestService>();            
            container.RegisterType<IControllerActivator, CustomControllerActivator>();
            
            container.RegisterType<IUserService, UserServiceClient>();
            container.RegisterType<IEmailService, EmailServiceClient>();
            container.RegisterType<IAuthoService, AuthoServiceClient>();
            return container;
        }
    }
}